<template>
  <div class="sibling-a">
    <h4>兄弟组件 A</h4>
    <p>从兄弟B接收的消息: {{ message }}</p>
    
    <div>
      <input 
        v-model="newMessage" 
        placeholder="输入消息发送给兄弟B"
      />
      <button @click="sendMessage">发送消息</button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const props = defineProps({
  message: {
    type: String,
    default: ''
  }
})

const emit = defineEmits(['message-from-a'])

const newMessage = ref('')

const sendMessage = () => {
  emit('message-from-a', newMessage.value)
  newMessage.value = ''
}
</script>

<style scoped>
.sibling-a {
  flex: 1;
  padding: 15px;
  background-color: #f0f7ff;
  border-radius: 6px;
}

.sibling-a div {
  margin: 10px 0;
}

.sibling-a input {
  padding: 8px;
  margin-right: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 70%;
}

.sibling-a button {
  padding: 8px 12px;
  background-color: #42b983;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.sibling-a button:hover {
  background-color: #369870;
}
</style>